﻿using ThomasGIS.Coordinates;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ThomasGIS.Projections
{
    public static class ProjectionGenerator
    {
        public static IProjection GenerateProjection(CoordinateBase coordinateBase)
        {
            if (coordinateBase.GetCoordinateType() == CoordinateType.Projected)
            {
                ProjectedCoordinate projectedCoordinate = coordinateBase as ProjectedCoordinate;
                string projectionName = projectedCoordinate.Projection;
                switch (projectionName)
                {
                    case "Gauss_Kruger":
                        return new GaussKrugerProjection(coordinateBase);
                    case "Mecator":
                        return new MecatorProjection(coordinateBase);
                    default:
                        throw new Exception("当前暂未支持的投影类型！");
                }
            }

            throw new Exception("非投影坐标系统，无法生成对象！");
        }

        public static IProjection GaussKrugerProjection(string name, double L0, double xOffset = 500000.0, double yOffset = 0)
        {
            return new GaussKrugerProjection(name, L0, xOffset, yOffset);
        }

        public static IProjection MecatorProjection(string name, double B0, double L0, double xOffset = 0, double yOffset = 0)
        {
            return new MecatorProjection(name, B0, L0, xOffset, yOffset);
        }

        public static ITransform BD09Transform()
        {
            return new BD09();
        }

        public static ITransform GCJ02Transform()
        {
            return new GCJ02();
        }
    }
}
